import org.apache.spark.sql.SparkSession

object Collect {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .appName("Test")
      .master("local[*]")
      .getOrCreate()
    val sc = spark.sparkContext

    val distData = sc.parallelize(List(1, 3, 45, 3, 76))
    val sq_dist = distData.map(x=>x*x)

    val data = sc.parallelize(List((1, 3),(45, 3),(7, 6)))
    val sort_data = data.sortBy(x => x._2, false, 1)

    println(sq_dist.collect())
    println(sort_data.collect())

    val one:PartialFunction[Int, String] = {case 1 => "one";case _ => "other"}
    val data1 = sc.parallelize(List(2, 3, 1))
    println(data1.collect(one).collect)


  }
}